﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using CodeGame.ServerObjects;

using Lidgren.Network;

namespace CodeGame.Networking.Serverside
{
    class ServerProtocolWorld
    {
        public static void SendWorldToClient(NetConnection client)
        {
            NetOutgoingMessage message = DedicatedServer.CreateMessage(ServerClientNet.WorldResponce);
            byte[] data = ServerSingletons.World.GetWorldData();
            message.Write(data.Length);
            message.Write(data);
            DedicatedServer.SendMessage(message, client);

            List<ServerObjects.Entity> ents = ServerSingletons.World.GetAllEntities();
            foreach (ServerObjects.Entity item in ents)
            {
                Console.WriteLine("Sending Entity");
                ServerProtocolEntity.CreateEntity(item.GetID(), item.X, item.Y, item.Angle, item.Texture, item.TintR, item.TintG, item.TintB);
            }

        }

    }
}
